import { Controller } from "../../mvc/core/Controller";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { GuildEventName } from "../view/guild/GuildEventName";
import { EventName } from "../mvc/EventName";
import { DataEvent } from "../events/DataEvent";
import { SGuildWarehouseApply } from "../../../Message/Game/SGuildWarehouseApply";
import { MsgManager } from "../manager/MsgManager";
import { Language } from "../../../extend/language/Language";
import { GameProxy } from "../mvc/GameProxy";
import { SPlayerItem } from "../../../Message/Public/SPlayerItem";
import { EGuildWarehouseOper } from "../../../Message/Game/EGuildWarehouseOper";
import { IView } from "../../mvc/interfaces/IView";
import { GuildWarehouseModule } from "../../../modules/GuildWarehouseModule";
import { PlayerEvent } from "../scene/events/PlayerEvent";
import { RolePlayer } from "../scene/player/entity/RolePlayer";
import { GameMapUtil } from "../scene/map/GameMapUtil";
import { SPlayerGuildInfo } from "../../../Message/Game/SPlayerGuildInfo";
import { ItemData } from "../resource/info/ItemData";
import { IWareHouseSellWindow } from "../../../modules/interfaces/IWareHouseSellWindow";
import { WareHouseSellWindow } from "../view/guild/warehouse/WareHouseSellWindow";
import { GameController } from "../mvc/GameController";
import { LayerManager } from "../manager/LayerManager";
import { MessageBlock } from "../../../Framework/MQ/MessageBlock";
import { SMarketResult } from "../../../Message/Game/SMarketResult";
import { SSeqMarketItem } from "../../../Message/Game/SSeqMarketItem";
import { Cache } from "../cache/Cache";
import { NpcEffectRule } from "../rules/NpcEffectRule";
import { NetDispatcher } from "../../mvc/core/NetDispatcher";
import { ServerCommand } from "../mvc/ServerCommand";
import { EGateCommand } from "../../../Message/Command/EGateCommand";
import { SGuildWarehouseUpdate } from "../../../Message/Game/SGuildWarehouseUpdate";
import { EPrictUnit } from "../../../Message/Public/EPrictUnit";
import { ApplyListWindow } from "../view/guild/warehouse/ApplyListWindow";
import { AssignConfirmWindow } from "../view/guild/warehouse/AssignConfirmWindow";
import { ReplyListWindow } from "../view/guild/warehouse/ReplyListWindow";
import { AssignItemWindow } from "../view/guild/warehouse/AssignItemWindow";
import { RecordListWindow } from "../view/guild/warehouse/RecordListWindow";
import { Global } from "../../../com/gengine/global/Global";
import { TakeOutConfirmWindow } from "../view/guild/warehouse/TakeOutConfirmWindow";
import { ContriConfirmWindow } from "../view/guild/warehouse/ContriConfirmWindow";
import { ApplyConfirmWindow } from "../view/guild/warehouse/ApplyConfirmWindow";
import { IGuildWarehouseModule } from "../../../modules/interfaces/IGuildWarehouseModule";
type int = number;
//class GuildWarehouseController
    
    export  class GuildWarehouseController extends Controller
    {
        constructor()
        {
            
            super();Dispatcher.addEventListener(GuildEventName.WarehouseOpenApplyWindow, this.onWarehouseOpenApplyWindowHandler);
            Dispatcher.addEventListener(GuildEventName.WarehouseOpenReplyWindow, this.onWarehouseOpenReplyWindowHandler);
            Dispatcher.addEventListener(GuildEventName.WarehouseOpenAssignWindow, this.onWarehouseOpenAssignWindowHandler);
            Dispatcher.addEventListener(GuildEventName.WarehouseOpenPackWindow, this.onWarehouseOpenPackWindowHandler);
            Dispatcher.addEventListener(GuildEventName.WarehouseOpenRecordWindow, this.onWarehouseOpenRecordWindowHandler);
            Dispatcher.addEventListener(GuildEventName.SortMember, this.onSortMemberHandler);
            Dispatcher.addEventListener(GuildEventName.WarehouseOpenAssignNumWindow, this.onWarehouseOpenAssignNumWindowHandler);
            Dispatcher.addEventListener(GuildEventName.WarehouseItemDoubleClick, this.onWarehouseItemDoubleClickHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseOpen, this.onGuildWarehouseOpenHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseClose, this.onGuildWarehouseCloseHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseGetItems, this.onGuildWarehouseGetItemsHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseGetItemsSuccess, this.onGuildWarehouseGetItemsSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseOper, this.onGuildWarehouseOperHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseOperSuccess, this.onGuildWarehouseOperSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseDestroy, this.onGuildWarehouseDestroyHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseContri, this.onGuildWarehouseContriHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseGetRecords, this.onGuildWarehouseGetRecordsHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseGetRecordsSuccess, this.onGuildWarehouseGetRecordsSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseApply, this.onGuildWarehouseApplyHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseApplySuccess, this.onGuildWarehouseApplySuccessHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseCancelApply, this.onGuildWarehouseCancelApplyHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseDraw, this.onGuildWarehouseDrawHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseAssign, this.onGuildWarehouseAssignHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseAssignSuccess, this.onGuildWarehouseAssignSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseReply, this.onGuildWarehouseReplyHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseReplySuccess, this.onGuildWarehouseReplySuccessHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseGetAllApply, this.onGuildWarehouseGetAllApplyHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseGetAllApplySuccess, this.onGuildWarehouseGetAllApplySuccessHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseGetSelfApply, this.onGuildWarehouseGetSelfApplyHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseGetSelfApplySuccess, this.onGuildWarehouseGetSelfApplySuccessHandler);
            Dispatcher.addEventListener(EventName.GuildWarehouseTake, this.onGuildWarehouseTakeHandler);
            Dispatcher.addEventListener(EventName.GuildWareHouseOpenSell, this.onOpenSellHandler);
            Dispatcher.addEventListener(EventName.GuildWareHouseSelfGoods, this.onGetSelfGoods);
            Dispatcher.addEventListener(EventName.GuildWareHouseCancelSell, this.onCancelSellHandler);
            Dispatcher.addEventListener(EventName.GuildWareHouseGotoSell, this.onGotoSellHandler);
            return;
        }

        /* internal  */onGuildWarehouseReplySuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["applyInfo"] as SGuildWarehouseApply;
            var loc2=arg1.data["result"] as Boolean;
            if (loc2) 
            {
                MsgManager.showRollTipsMsg(Language.getString(57381));
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(57382));
            }
            if (this._replyListWindow) 
            {
                this._replyListWindow.removeReplyedApply(loc1);
            }
            return;
        }

        /* internal  */onGuildWarehouseGetAllApplyHandler(arg1: DataEvent): void
        {
            GameProxy.guildProxy.getAllGuildWarehouseApplys();
            return;
        }

        /* internal  */onGuildWarehouseGetAllApplySuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as Array<any>;
            if (this._replyListWindow && this._replyListWindow.isHide == false) 
            {
                this._replyListWindow.setDefaultPage(loc1);
            }
            return;
        }

        /* internal  */onGuildWarehouseGetSelfApplyHandler(arg1: DataEvent): void
        {
            GameProxy.guildProxy.getGuildWarehouseApplys();
            return;
        }

        /* internal  */onGuildWarehouseGetSelfApplySuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as Array<any>;
            if (this._applyListWindow && this._applyListWindow.isHide == false) 
            {
                this._applyListWindow.setDefaultPage(loc1);
            }
            return;
        }

        /* internal  */onGuildWarehouseTakeHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as SPlayerItem;
            if (loc1) 
            {
                if (!cache.guild.isCanManageWarehouse()) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(57383));
                    return;
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarehouseOper, {"oper": EGuildWarehouseOper.convert(EGuildWarehouseOper._EGuildWarehouseOut), "item": loc1}));
            }
            return;
        }

        protected /* override */ initView(): IView
        {
            if (this._warehouseModule == null) 
            {
                this._warehouseModule = new GuildWarehouseModule();
                this._warehouseModule.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddedToStageHandler);
            }
            return this._warehouseModule;
        }

        /* internal  */onGirdWalkEnd(arg1: PlayerEvent): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=NaN;
            if (this.isWarehouseOpenByNpc) 
            {
                loc1 = RolePlayer.instance.currentPoint;
                if (this._warehouseModule && this._warehouseModule.isHide == false) 
                {
                    loc2 = cache.dialog.npcInfo;
                    if (loc2) 
                    {
                        loc3 = GameMapUtil.getPixelPoint(loc2.snpc.point.x, loc2.snpc.point.y);
                        if ((loc4 = Math.sqrt(Math.pow(loc3.x - loc1.x, 2) + Math.pow(loc3.y - loc1.y, 2))) > 120) 
                        {
                            this._warehouseModule.hide();
                            this.onGuildWarehouseCloseHandler(null);
                        }
                    }
                }
            }
            return;
        }

        /* internal  */onGuildUpdateInfoHandler(arg1: SPlayerGuildInfo): void
        {
            if (this._warehouseModule) 
            {
                this._warehouseModule.updateRightMenu();
                this._warehouseModule.updateOperMenu();
            }
            return;
        }

        /* internal  */onWarehouseItemDoubleClickHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as SPlayerItem;
            if (loc1) 
            {
                if ((this._applyListWindow == null || this._applyListWindow.isHide == true) && (this._assignWindow == null || this._assignWindow.isHide == true)) 
                {
                    if (this.sellWindow && !this.sellWindow.isHide) 
                    {
                        this.sellWindow.setSellGoodsItem(new ItemData(loc1));
                        return;
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarehouseTake, loc1));
                }
                else if (this._applyListWindow && this._applyListWindow.isHide == false) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(GuildEventName.WarehouseSendToApply, loc1));
                }
                else if (this._assignWindow && this._assignWindow.isHide == false) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(GuildEventName.WarehouseSendToAssign, loc1));
                }
            }
            return;
        }

        public get isWarehouseOpenByNpc(): Boolean
        {
            return this._isWarehouseOpenByNpc;
        }

        public init(): void
        {
            return;
        }

        public /* override */ get view(): IView
        {
            return this.initView();
        }

        public set isWarehouseOpenByNpc(arg1: Boolean)
        {
            this._isWarehouseOpenByNpc = arg1;
            return;
        }

        public get sellWindow(): IWareHouseSellWindow
        {
            if (this._WareHouseSellWindow == null) 
            {
                this._WareHouseSellWindow = new WareHouseSellWindow();
            }
            return this._WareHouseSellWindow;
        }

        /* internal  */onOpenSellHandler(arg1: DataEvent): void
        {
            var loc1=null;
            if (arg1.data != null) 
            {
                loc1 = arg1.data as ItemData;
                this.sellWindow.show();
                this.sellWindow.setSellGoodsItem(loc1);
            }
            if (this.sellWindow.isHide) 
            {
                this.sellWindow.show();
            }
            else if (arg1.data == null && !this.sellWindow.isHide) 
            {
                this.sellWindow.hide();
            }
            if (!GameController.pack.view.isHide) 
            {
                GameController.pack.view.hide();
            }
            if (this.isShow()) 
            {
                LayerManager.windowLayer.centerWindows(this._warehouseModule, this.sellWindow);
            }
            return;
        }

        /* internal  */onGetSelfGoods(arg1: DataEvent): void
        {
            var loc1=arg1.data as Boolean;
            if (this.sellWindow.isHide) 
            {
                this.sellWindow.show();
                this.sellWindow.updateSelfGoods();
            }
            else if (loc1) 
            {
                this.sellWindow.hide();
            }
            if (this.sellWindow.isHide) 
            {
                return;
            }
            GameProxy.guildProxy.getMySells();
            return;
        }

        /* internal  */onCancelSellHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data;
            var loc2=loc1.marketId as number;
            GameProxy.guildProxy.cancelSell(loc2);
            return;
        }

        /* internal  */onGotoSellHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data;
            var loc2=loc1.code as int;
            var loc3=loc1.itemUid as string;
            var loc4=loc1.amount as int;
            var loc5=loc1.price as int;
            var loc6=loc1.unit as int;
            var loc7=loc1.time as int;
            var loc8=loc1.broadcast as Boolean;
            GameProxy.guildProxy.sellItem(loc2, loc3, loc4, loc5, loc6, loc7, loc8);
            return;
        }

        /* internal  */onMarketResultSellItemHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SMarketResult;
            if (loc1.result) 
            {
                MsgManager.showRollTipsMsg(Language.getString(31002));
                this.sellWindow.resetWindow();
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(31003));
            }
            return;
        }

        /* internal  */onMarketSearchCancelSellHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SMarketResult;
            if (loc1.result) 
            {
                GameProxy.guildProxy.getMySells();
                MsgManager.showRollTipsMsg(Language.getString(31004));
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(31005));
            }
            return;
        }

        /* internal  */onMarketGetMySellsResultHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SSeqMarketItem;
            Cache.instance.pack.wareHousePackCache.sSeqMarketItemSell = loc1;
            if (this.sellWindow.curSelectedIndex == 1) 
            {
                this.sellWindow.updateSelfGoods();
            }
            return;
        }

        /* internal  */onAddedToStageHandler(arg1: Object /* flash.events.Event */): void
        {
            NpcEffectRule.registDialogEffectWindow(this.view);
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarehouseGetItems));
            return;
        }

        protected /* override */ initServer(): void
        {
            NetDispatcher.addCmdListener(ServerCommand.GuildWarehouseUpdateCommand, this.onGuildWarehouseUpdateCommandHandler);
            NetDispatcher.addCmdListener(ServerCommand.GuildWarehouseApplyUpdateCommand, this.onGuildWarehouseApplyUpdateCommandHandler);
            NetDispatcher.addCmdListener(ServerCommand.GuildUpdateInfo, this.onGuildUpdateInfoHandler);
            NetDispatcher.addCmdListener(EGateCommand._ECmdGateMarketGetGuildSells, this.onMarketGetMySellsResultHandler);
            NetDispatcher.addCmdListener(EGateCommand._ECmdGateMarketResultSellGuildItem, this.onMarketResultSellItemHandler);
            NetDispatcher.addCmdListener(EGateCommand._ECmdGateMarketSearchCancelGuildSell, this.onMarketSearchCancelSellHandler);
            return;
        }

        /* internal  */onGuildWarehouseUpdateCommandHandler(arg1: SGuildWarehouseUpdate): void
        {
            var loc1=arg1.items;
            if (this._warehouseModule) 
            {
                this._warehouseModule.setAllPlayerItem(loc1);
                this._warehouseModule.setDefaultPage(loc1);
                this._warehouseModule.showDefaultTab();
                this._warehouseModule.updateMoney(arg1.moneyMap);
                this.sellWindow.updateMoney(arg1.moneyMap);
            }
            if (this._assignWindow && !this._assignWindow.isHide) 
            {
                this._assignWindow.updateMaxGold(int(arg1.moneyMap[EPrictUnit._EPriceUnitGold]));
            }
            return;
        }

        /* internal  */onGuildWarehouseApplyUpdateCommandHandler(arg1: Array<any>): void
        {
            if (arg1) 
            {
                if (this._applyListWindow && this._applyListWindow.isHide == false) 
                {
                    this._applyListWindow.setDefaultPage(arg1);
                }
            }
            return;
        }

        public isShow(): Boolean
        {
            return this._warehouseModule && this._warehouseModule.isHide == false;
        }

        /* internal  */onWarehouseOpenApplyWindowHandler(arg1: DataEvent): void
        {
            if (this._applyListWindow == null) 
            {
                this._applyListWindow = new ApplyListWindow();
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarehouseGetSelfApply));
            this.onGuildWarehouseCloseHandler(null);
            this._applyListWindow.show(825, this._warehouseModule.y);
            return;
        }

        /* internal  */onWarehouseOpenAssignNumWindowHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["itemData"] as ItemData;
            var loc2=arg1.data["posIndex"] as int;
            var loc3;
            (loc3 = new ItemData(loc1.itemCode)).data.uid = loc1.uid;
            loc3.data.itemAmount = loc1.itemAmount;
            loc3.data.itemCode = loc1.itemCode;
            if (this._assignConfirmWindow == null) 
            {
                this._assignConfirmWindow = new AssignConfirmWindow();
            }
            this._assignConfirmWindow.toIndex = loc2;
            this._assignConfirmWindow.updateByItemData(loc3);
            this._assignConfirmWindow.show();
            return;
        }

        /* internal  */onWarehouseOpenReplyWindowHandler(arg1: DataEvent): void
        {
            if (this._replyListWindow == null) 
            {
                this._replyListWindow = new ReplyListWindow();
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarehouseGetAllApply));
            this.onGuildWarehouseCloseHandler(null);
            this._replyListWindow.show(825, this._warehouseModule.y);
            return;
        }

        /* internal  */onWarehouseOpenAssignWindowHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as int;
            if (this._assignWindow == null) 
            {
                this._assignWindow = new AssignItemWindow();
            }
            this._assignWindow.updateMaxGold(loc1);
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildGetPlayerList, cache.guild.myGuildInfo.guildId));
            this.onGuildWarehouseCloseHandler(null);
            this._assignWindow.show(825, this._warehouseModule.y);
            return;
        }

        /* internal  */onWarehouseOpenPackWindowHandler(arg1: DataEvent): void
        {
            GameController.pack.view.show(815, this._warehouseModule.y);
            return;
        }

        /* internal  */onWarehouseOpenRecordWindowHandler(arg1: DataEvent): void
        {
            if (this._recordWindow == null) 
            {
                this._recordWindow = new RecordListWindow();
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarehouseGetRecords, cache.guild.myGuildInfo.guildId));
            this.onGuildWarehouseCloseHandler(null);
            if (this._warehouseModule != null) 
            {
                this._recordWindow.show(825, this._warehouseModule.y);
            }
            else 
            {
                this._recordWindow.show();
            }
            return;
        }

        /* internal  */onSortMemberHandler(arg1: DataEvent): void
        {
            var loc1=null;
            var loc2=null;
            if (this._assignWindow && this._assignWindow.isHide == false) 
            {
                loc1 = arg1.data as string;
                loc2 = cache.guild.getSortedMemberArray(loc1);
                this._assignWindow.setDefaultPage(loc2);
            }
            return;
        }

        /* internal  */onGuildWarehouseOpenHandler(arg1: DataEvent): void
        {
            if (cache.guild.getWarehouseLevel() < 1) 
            {
                MsgManager.showRollTipsMsg(Language.getString(57376));
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.CloseGuildWindow));
            var loc1=(Global.stage.stageHeight - GameController.pack.view.height) / 2;
            this.view.show(380, loc1);
            GameController.pack.view.show(825, loc1);
            return;
        }

        /* internal  */onGuildWarehouseCloseHandler(arg1: DataEvent): void
        {
            if (this._replyListWindow) 
            {
                this._replyListWindow.hide();
            }
            if (this._assignWindow) 
            {
                this._assignWindow.hide();
            }
            if (this._recordWindow) 
            {
                this._recordWindow.hide();
            }
            if (this._applyListWindow) 
            {
                this._applyListWindow.hide();
            }
            if (this._contriWindow) 
            {
                this._contriWindow.hide();
            }
            if (this._applyConfirmWindow) 
            {
                this._applyConfirmWindow.hide();
            }
            if (this._assignConfirmWindow) 
            {
                this._assignConfirmWindow.hide();
            }
            if (GameController.pack.isViewShow) 
            {
                GameController.pack.view.hide();
            }
            return;
        }

        /* internal  */onGuildWarehouseGetItemsHandler(arg1: DataEvent): void
        {
            GameProxy.guildProxy.getGuildWarehouses();
            return;
        }

        /* internal  */onGuildWarehouseGetItemsSuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["itemsArray"] as Array<any>;
            var loc2=arg1.data["moneyMap"] as Map<any, any> /* flash.utils.Dictionary */;
            if (this._warehouseModule && !this._warehouseModule.isHide) 
            {
                this._warehouseModule.setAllPlayerItem(loc1);
                this._warehouseModule.setDefaultPage(loc1);
                this._warehouseModule.updateMoney(loc2);
                this.sellWindow.updateMoney(loc2);
            }
            return;
        }

        /* internal  */onGuildWarehouseOperHandler(arg1: DataEvent): void
        {
            var dataEvent: DataEvent;
            var oper: EGuildWarehouseOper;
            var item: SPlayerItem;
            var moneyMap: Map<any, any> /* flash.utils.Dictionary */;
            var configHandler: Function;

            var loc1;
            oper = null;
            moneyMap = null;
            configHandler = null;
            dataEvent = arg1;
            configHandler = (arg1: SPlayerItem): void
            {
                GameProxy.guildProxy.operGuildWarehouse(oper, arg1, moneyMap);
                return;
            }
            oper = dataEvent.data["oper"] as EGuildWarehouseOper;
            item = dataEvent.data["item"] as SPlayerItem;
            moneyMap = dataEvent.data["moneyMap"] as Map<any, any> /* flash.utils.Dictionary */;
            if ((oper.value() == EGuildWarehouseOper._EGuildWarehouseOut || oper.value() == EGuildWarehouseOper._EGuildWarehouseSellOut) && item && item.itemAmount > 1) 
            {
                if (this._takeOutContriWindow == null) 
                {
                    this._takeOutContriWindow = new TakeOutConfirmWindow();
                }
                this._takeOutContriWindow.updateByItemData(new ItemData(item), configHandler);
                this._takeOutContriWindow.show();
            }
            else 
            {
                GameProxy.guildProxy.operGuildWarehouse(oper, item, moneyMap);
            }
            return;
        }

        /* internal  */onGuildWarehouseContriHandler(arg1: DataEvent): void
        {
            var loc1=EGuildWarehouseOper.convert(EGuildWarehouseOper._EGuildWarehouseIn);
            var loc2=arg1.data as ItemData;
            if (loc2) 
            {
                this.onGuildWarehouseCloseHandler(null);
                if (this._contriWindow == null) 
                {
                    this._contriWindow = new ContriConfirmWindow();
                }
                this._contriWindow.updateByItemData(loc2);
                this._contriWindow.show();
                if (this._warehouseModule) 
                {
                    this._contriWindow.x = this._warehouseModule.x + 70;
                    this._contriWindow.y = this._warehouseModule.y + 95;
                }
                this.onWarehouseOpenPackWindowHandler(null);
            }
            return;
        }

        /* internal  */onGuildWarehouseOperSuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["oper"] as EGuildWarehouseOper;
            var loc2=arg1.data["moneyMap"] as Map<any, any> /* flash.utils.Dictionary */;
            if (loc1.value() != EGuildWarehouseOper._EGuildWarehouseIn) 
            {
                MsgManager.showRollTipsMsg(Language.getString(57378));
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(57377));
            }
            this._warehouseModule.updateMoney(loc2);
            this.sellWindow.updateMoney(loc2);
            this._warehouseModule.resetMoney();
            return;
        }

        /* internal  */onGuildWarehouseDestroyHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as string;
            GameProxy.guildProxy.destroyGuildWarehouse(loc1);
            return;
        }

        /* internal  */onGuildWarehouseGetRecordsHandler(arg1: DataEvent): void
        {
            GameProxy.guildProxy.getGuildWarehouseRecords();
            return;
        }

        /* internal  */onGuildWarehouseGetRecordsSuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as Array<any>;
            cache.guild.warehouseRecodsArray = loc1;
            if (this._recordWindow && this._recordWindow.isHide == false) 
            {
                this._recordWindow.setDefaultPage(cache.guild.warehouseRecodsArray);
            }
            return;
        }

        /* internal  */onGuildWarehouseApplyHandler(arg1: DataEvent): void
        {
            var loc3=null;
            var loc4=0;
            var loc5=null;
            var loc1=arg1.data["playerItem"] as SPlayerItem;
            var loc2=arg1.data["moneyMap"] as Map<any, any> /* flash.utils.Dictionary */;
            if (loc1) 
            {
                if (loc1.itemAmount > 1) 
                {
                    (loc5 = new ItemData(loc1.itemCode)).data.uid = loc1.uid;
                    loc5.itemAmount = loc1.itemAmount;
                    if (this._applyConfirmWindow == null) 
                    {
                        this._applyConfirmWindow = new ApplyConfirmWindow();
                    }
                    this._applyConfirmWindow.updateByItemData(loc5);
                    this._applyConfirmWindow.show();
                }
                else 
                {
                    if (this._applyConfirmWindow && this._applyConfirmWindow.isHide == false) 
                    {
                        this._applyConfirmWindow.hide();
                    }
                    loc3 = loc1.uid;
                    loc4 = loc1.itemAmount;
                    GameProxy.guildProxy.applyGuildWarehouse(loc3, loc4, loc2);
                }
            }
            else 
            {
                GameProxy.guildProxy.applyGuildWarehouse("", 0, loc2);
            }
            return;
        }

        /* internal  */onGuildWarehouseApplySuccessHandler(arg1: DataEvent): void
        {
            MsgManager.showRollTipsMsg(Language.getString(57379));
            return;
        }

        /* internal  */onGuildWarehouseCancelApplyHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["moneyMap"] as Map<any, any> /* flash.utils.Dictionary */;
            GameProxy.guildProxy.cancelApplyGuildWarehouse(loc1, loc2);
            return;
        }

        /* internal  */onGuildWarehouseDrawHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as string;
            GameProxy.guildProxy.drawGuildWarehouse(loc1);
            return;
        }

        /* internal  */onGuildWarehouseAssignHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["toPlayerId"] as int;
            var loc2=arg1.data["itemMap"] as Map<any, any> /* flash.utils.Dictionary */;
            var loc3=arg1.data["moneyMap"] as Map<any, any> /* flash.utils.Dictionary */;
            GameProxy.guildProxy.assignGuildWarehouse(loc1, loc2, loc3);
            return;
        }

        /* internal  */onGuildWarehouseAssignSuccessHandler(arg1: DataEvent): void
        {
            this._assignWindow.resetToDefault();
            MsgManager.showRollTipsMsg(Language.getString(57380));
            return;
        }

        /* internal  */onGuildWarehouseReplyHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["toPlayerId"] as int;
            var loc2=arg1.data["applyInfo"] as SGuildWarehouseApply;
            var loc3=arg1.data["result"] as Boolean;
            var loc4=arg1.data["moneyMap"] as Map<any, any> /* flash.utils.Dictionary */;
            GameProxy.guildProxy.replyGuildWarehouse(loc1, loc2, loc3, loc4);
            return;
        }

        private /* var */_isWarehouseOpenByNpc: Boolean;

        private /* var */_warehouseModule: IGuildWarehouseModule;

        private /* var */_takeOutContriWindow: TakeOutConfirmWindow;

        private /* var */_contriWindow: ContriConfirmWindow;

        private /* var */_applyListWindow: ApplyListWindow;

        private /* var */_applyConfirmWindow: ApplyConfirmWindow;

        private /* var */_assignWindow: AssignItemWindow;

        private /* var */_recordWindow: RecordListWindow;

        private /* var */_assignConfirmWindow: AssignConfirmWindow;

        private /* var */_WareHouseSellWindow: IWareHouseSellWindow;

        private /* var */_replyListWindow: ReplyListWindow;
    }
